<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
	if (null != request.getParameter("page") && !"".equals(request.getParameter("page"))) {
		session.setAttribute("page", request.getParameter("page"));
	}
	
%>
<span id="txt" style="display:none;">正在使用微信登录...</span>
<script src="<%=basePath%>js/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
	oauth2();
	function oauth2() {
		var ctx = "${pageContext.request.contextPath}";
		if (is_weixn()) {
			$("#txt").show();
			var redirect_uri = encodeURIComponent("http://www.xunbaoo.com/redPacket/wx/oauth?page=${page}");
			var url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc6dc67749e9e5ba8&redirect_uri="+redirect_uri+"&response_type=code&scope=snsapi_userinfo&connect_redirect=1&state=STATE#wechat_redirect";
			window.location.href = url;
		} else {
			$("#txt").hide();
			window.location.href = ctx+"/login.jsp";
		}
	}
	
	function is_weixn(){  
	    var ua = navigator.userAgent.toLowerCase();  
	    if(ua.match(/MicroMessenger/i)=="micromessenger") {  
	        return true;  
	    } else {  
	        return false;  
	    }  
	}  
</script>